package pers.zw.study.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;

@WebServlet(name = "DrawVerificationCode", urlPatterns = "/DrawVerificationCode")
public class DrawVerificationCode extends HttpServlet {
    private static final long serialVersionUID = 3038623696184546092L;

    public static final int WIDTH = 120;
    public static final int HEIGHT = 30;

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String createTypeFlag = request.getParameter("createTypeFlag");
        //1. 内存中创建图片
        BufferedImage bi = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
        //2.得到图片
        Graphics g = bi.getGraphics();
        //3.设置图片的背影色
        //setBackground(g);
        //4.设置图片的边框
        //setBorder(g);
        //5.在图片上画干扰线
        //drawRandomLine(g);
        //6.往图片上写随机数
        //String random = drawRandomNum((Graphics2D) g, createTypeFlag);
        //7.将随机数存在session中
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
